﻿using Triples;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Text.RegularExpressions;

namespace Triples
{
    
    
    /// <summary>
    ///This is a test class for TripleTest and is intended
    ///to contain all TripleTest Unit Tests
    ///</summary>
    [TestClass()]
    public class TripleTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
          
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Triple Constructor
        ///</summary>
        [TestMethod()]
        public void TripleConstructorTest()
        {
            int a = -200; // TODO: Initialize to an appropriate value
            int b = 30; // TODO: Initialize to an appropriate value
            int c = 12; // TODO: Initialize to an appropriate value
            Triple target = new Triple(a, b, c);

            Assert.AreEqual(a, target.A);
            Assert.AreEqual(b, target.B);
            Assert.AreEqual(c, target.C);
        }

        /// <summary>
        ///A test for Clone
        ///</summary>
        [TestMethod()]
        public void CloneTest()
        {
            int a = -16; 
            int b = 0; 
            int c = 12;
            Triple target = new Triple(a, b, c);
            object expected = new Triple(a, b, c);
            object actual;
            actual = target.Clone();
            Assert.AreEqual(((Triple)expected).A , ((Triple)actual).A);
            Assert.AreEqual(((Triple)expected).B, ((Triple)actual).B);
            Assert.AreEqual(((Triple)expected).C, ((Triple)actual).C);

        }

        [TestMethod()]
        public void CloneTestAfterChange()
        {
            int a = 1;
            int b = 2; 
            int c = 3; 
            Triple target = new Triple(a, b, c); 
            object expected = new Triple(30, 20, 50);
            object actual;
            actual = target.Clone();
            Assert.AreNotEqual(((Triple)expected).A, ((Triple)actual).A);
            Assert.AreNotEqual(((Triple)expected).B, ((Triple)actual).B);
            Assert.AreNotEqual(((Triple)expected).C, ((Triple)actual).C);

        }

        /// <summary>
        ///A test for CompareTo
        ///</summary>
        [TestMethod()]
        public void CompareToTest()
        {
            int a = 30;
            int b = 12; 
            int c = 20; 
            Triple target = new Triple(a, b, c);
            Triple other = new Triple(a, b, c);
            int expected = 0;
            int actual;
            actual = target.CompareTo(other);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void CompareToTestFirstIsGreater()
        {
            int a = 30;
            int b = 12;
            int c = 20;
            Triple target = new Triple(a, b, c);
            Triple other = new Triple(50, -20, 3);
            int expected = 1;
            int actual;
            actual = target.CompareTo(other);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void CompareToTestFirstIsSmaller()
        {
            int a = 30;
            int b = 12;
            int c = 20;
            Triple target = new Triple(a, b, c);
            Triple other = new Triple(50, 20, 3);
            int expected = -1;
            int actual;
            actual = target.CompareTo(other);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for FindAllTriplesInText
        ///</summary>
        [TestMethod()]
        public void FindAllTriplesInTextTest()
        {
            string filename = @"C:\Users\Home\Documents\visual studio 2010\Projects\SampleFirstExam\Triples\bin\Debug\triples.in";
            string[] expected = new string[] { "(1, 2, 3)","(-5, -2, 3)"};
            Match actual;
            actual = Triple.FindAllTriplesInText(filename);

            Assert.AreEqual(actual.Value, expected[0]);
            Assert.AreEqual(actual.NextMatch().Value, expected[1]);
        }

        [TestMethod()]
        public void FindAllTriplesInTextNumberOfMatchesTest()
        {
            string filename = @"C:\Users\Home\Documents\visual studio 2010\Projects\SampleFirstExam\Triples\bin\Debug\triples.in";
            string[] expected = new string[] { "(1, 2, 3)", "(-5, -2, 3)" };
            Match actual;
            actual = Triple.FindAllTriplesInText(filename);

            int numberOfmatches = 0;
            while (actual.Success)
            {
                numberOfmatches++;
                actual = actual.NextMatch();
            }

            Assert.AreEqual(numberOfmatches, 2);
        }

        /// <summary>
        ///A test for SumComponents
        ///</summary>
        [TestMethod()]
        public void SumComponentsTest()
        {
            int a = -20;
            int b = 3;
            int c = 16; 
            Triple target = new Triple(a, b, c);
            int expected = a+b+c;
            int actual;
            actual = target.SumComponents();
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for ToString
        ///</summary>
        [TestMethod()]
        public void ToStringTest()
        {
            int a = 16; // TODO: Initialize to an appropriate value
            int b = 3; // TODO: Initialize to an appropriate value
            int c = 8; // TODO: Initialize to an appropriate value
            Triple target = new Triple(a, b, c); // TODO: Initialize to an appropriate value
            string expected = "(16, 3, 8)";
            string actual;
            actual = target.ToString();

            Assert.AreEqual(actual, expected);
        }

        /// <summary>
        ///A test for op_Addition
        ///</summary>
        [TestMethod()]
        public void op_AdditionTest()
        {
            Triple first = new Triple(5, 3, -200);
            Triple second = new Triple(16, 0, 12);
            Triple expected = new Triple(21, 3, -188);
            Triple actual;
            actual = (first + second);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for op_Increment
        ///</summary>
        [TestMethod()]
        public void op_IncrementTest()
        {
            Triple first = new Triple(5, -1, 3);
            Triple expected = new Triple(6, 0, 4);
            Triple actual;
            actual = ++(first);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for op_Subtraction
        ///</summary>
        [TestMethod()]
        public void op_SubtractionTest()
        {
            Triple first = new Triple(5, 3, 1);
            Triple second = new Triple(0, 0, -10);
            Triple expected = new Triple(5, 3, 11);
            Triple actual;
            actual = (first - second);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for A
        ///</summary>
        [TestMethod()]
        public void ATest()
        {
            int a = 30; 
            int b = 12;
            int c = 2;
            Triple target = new Triple(a, b, c); // TODO: Initialize to an appropriate value
            int expected = 30; // TODO: Initialize to an appropriate value
            int actual;
            target.A = expected;
            actual = target.A;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for B
        ///</summary>
        [TestMethod()]
        public void BTest()
        {
            int a = 30;
            int b = 12; 
            int c = 2; 
            Triple target = new Triple(a, b, c);
            int expected = 12; 
            int actual;
            target.B = expected;
            actual = target.B;
            Assert.AreEqual(expected, actual);
           
        }

        /// <summary>
        ///A test for C
        ///</summary>
        [TestMethod()]
        public void CTest()
        {
            int a = 30;
            int b = 12; 
            int c = 2; 
            Triple target = new Triple(a, b, c);
            int expected = 2;
            int actual;
            target.C = expected;
            actual = target.C;
            Assert.AreEqual(expected, actual);
           
        }
    }
}
namespace BinarySplitterTests
{
    
    
    /// <summary>
    ///This is a test class for TripleTest and is intended
    ///to contain all TripleTest Unit Tests
    ///</summary>
    [TestClass()]
    public class TripleTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Equals
        ///</summary>
        [TestMethod()]
        public void EqualsTrueTest()
        {
            Triple target = new Triple(2, 3, 5); // TODO: Initialize to an appropriate value
            object toCompareWith = new Triple(2, 3, 5);
            bool expected = true;
            bool actual;
            actual = target.Equals(toCompareWith);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void EqualsFalseTest()
        {
            Triple target = new Triple(2, 3, 5); // TODO: Initialize to an appropriate value
            object toCompareWith = new Triple(8, 3, 5);
            bool expected = false;
            bool actual;
            actual = target.Equals(toCompareWith);
            Assert.AreEqual(expected, actual);
        }
    }
}
